package com.sky.utils;

import java.util.UUID;

/**
 * @author ghy
 * @version 1.0.1
 * @date 2023-04-20 12:02:52
 */
public class UUIDUtils {

    /**
     * 修改文件名为随机字符串
     * @param filename
     * @return
     */
    public static String getUUIDName(String filename){
        //a.jpg   c.png  d.txt
        //sdfljfo2340589fsdhjnkfsd.jpg
        String suffixName = filename.substring(filename.lastIndexOf("."));
        return getUUID().concat(suffixName);
    }

    /**
     * 获取一个没有-的随机UUID字符串
     * @return
     */
    public static String getUUID(){
        return UUID.randomUUID().toString().replaceAll("-", "");
    }
}
